﻿/********************************************************************************
 * Custom tool for generating entities and partial class from .dbml
 * Author: Papn Kukn (papnkukn@gmail.com)
 * Modified: 2009-07-22
 * Comments: design a .dbml document in Visual Studio
 *           (e.g. add a new item "LINQ to SQL Classes")
 *           then instead of using internal custom tool use this tool
 *           to generate code for Silverlight and SilverDatabase library
 ********************************************************************************/

using System;
using System.IO;
using System.Text;
using System.Xml;

namespace CustomTool
{
	class Program
	{
		static void Main(string[] args)
		{
			string filename = @"E:\source\csharp\sonce_new\Editor\Data\Model.dbml";

			string dbml = File.ReadAllText(filename);

			string code = DbmlFactory.GenerateEntities(dbml);
			string entities = filename.Replace(".dbml", ".entities.cs");
			File.WriteAllText(entities, code);

			code = DbmlFactory.GeneratePartialDatabaseClass(dbml);
			string context = filename.Replace(".dbml", ".context.cs");
			File.WriteAllText(context, code);
		}
	}
}
